/**
 */
package wcomm_v1.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import wcomm_v1.Plug;
import wcomm_v1.Service;
import wcomm_v1.Socket;
import wcomm_v1.Wcomm_v1Package;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Service</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link wcomm_v1.impl.ServiceImpl#getPlug <em>Plug</em>}</li>
 *   <li>{@link wcomm_v1.impl.ServiceImpl#getSocket <em>Socket</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ServiceImpl extends DocumentableElementImpl implements Service
{
  /**
   * The cached value of the '{@link #getPlug() <em>Plug</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPlug()
   * @generated
   * @ordered
   */
  protected Plug plug;

  /**
   * The cached value of the '{@link #getSocket() <em>Socket</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSocket()
   * @generated
   * @ordered
   */
  protected Socket socket;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ServiceImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return Wcomm_v1Package.Literals.SERVICE;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Plug getPlug()
  {
    return plug;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetPlug(Plug newPlug, NotificationChain msgs)
  {
    Plug oldPlug = plug;
    plug = newPlug;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Wcomm_v1Package.SERVICE__PLUG, oldPlug, newPlug);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setPlug(Plug newPlug)
  {
    if (newPlug != plug)
    {
      NotificationChain msgs = null;
      if (plug != null)
        msgs = ((InternalEObject)plug).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Wcomm_v1Package.SERVICE__PLUG, null, msgs);
      if (newPlug != null)
        msgs = ((InternalEObject)newPlug).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Wcomm_v1Package.SERVICE__PLUG, null, msgs);
      msgs = basicSetPlug(newPlug, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Wcomm_v1Package.SERVICE__PLUG, newPlug, newPlug));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Socket getSocket()
  {
    return socket;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetSocket(Socket newSocket, NotificationChain msgs)
  {
    Socket oldSocket = socket;
    socket = newSocket;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Wcomm_v1Package.SERVICE__SOCKET, oldSocket, newSocket);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setSocket(Socket newSocket)
  {
    if (newSocket != socket)
    {
      NotificationChain msgs = null;
      if (socket != null)
        msgs = ((InternalEObject)socket).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Wcomm_v1Package.SERVICE__SOCKET, null, msgs);
      if (newSocket != null)
        msgs = ((InternalEObject)newSocket).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Wcomm_v1Package.SERVICE__SOCKET, null, msgs);
      msgs = basicSetSocket(newSocket, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Wcomm_v1Package.SERVICE__SOCKET, newSocket, newSocket));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case Wcomm_v1Package.SERVICE__PLUG:
        return basicSetPlug(null, msgs);
      case Wcomm_v1Package.SERVICE__SOCKET:
        return basicSetSocket(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case Wcomm_v1Package.SERVICE__PLUG:
        return getPlug();
      case Wcomm_v1Package.SERVICE__SOCKET:
        return getSocket();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case Wcomm_v1Package.SERVICE__PLUG:
        setPlug((Plug)newValue);
        return;
      case Wcomm_v1Package.SERVICE__SOCKET:
        setSocket((Socket)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case Wcomm_v1Package.SERVICE__PLUG:
        setPlug((Plug)null);
        return;
      case Wcomm_v1Package.SERVICE__SOCKET:
        setSocket((Socket)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case Wcomm_v1Package.SERVICE__PLUG:
        return plug != null;
      case Wcomm_v1Package.SERVICE__SOCKET:
        return socket != null;
    }
    return super.eIsSet(featureID);
  }

} //ServiceImpl
